import { _decorator, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
import { UIManager } from '../../../FrameWork3.8.6/FrameWork/UIFramework/UIManager';
import { PlayerPropertyBase } from '../../UI/PlayerPropertyBase';
import { PropertyDt } from '../../../FrameWork3.8.6/FrameWork/Common/CommonInterface';
import { ResMgr } from '../../../FrameWork3.8.6/FrameWork/Res/ResMgr';
import { BundleConfig } from '../../../FrameWork3.8.6/FrameWork/NeedToChange/BundleConfig';
const { ccclass, property } = _decorator;

@ccclass('GridButton')
export class GridButton extends Component{
    //用于识别这是什么类型的网格栏
    private _curPropertyDt:PropertyDt=null;
    get curPropertyDt(){
        return this._curPropertyDt;
    }
    
    private _num:number=1;
    get num(){
        return this._num;
    }
    set num(num:number){
        this._num=num;
    }
    //网格初始化的方法
    onInit(curPropertyDt:PropertyDt){
        this._curPropertyDt=curPropertyDt;
        this.node.getChildByName("_NumLabel").getComponent(Label).string="x"+this._num;
        let img=ResMgr.instance.getRes<SpriteFrame>(BundleConfig.Img.name,curPropertyDt.iconName);
        let sprite=this.node.getComponent(Sprite);
        if(img){
            sprite.spriteFrame=img;
        }
    }
}


